/*
 *  SPUKMK3me - Rendering library for 2D game.
 *  Copyright 2012  H2KPigman
 *
 *   SPUKMK2me is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   SPUKMK2me is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *  along with SPUKMK2me.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.spukmk3me.video;

import com.spukmk3me.math.Matrix4f;
import com.spukmk3me.math.Rectangle;
import com.spukmk3me.scene.Entity;

public abstract class VideoAPI
{
    /**
     *  Initialize the video API.
     */
    public abstract void init();
    
    /**
     *  Cleanup.
     */
    public abstract void cleanup();
    
    /**
     *  Internal use only.
     *  \details Is called before rendering anything. Transform matrix is set
     *  to identity matrix and will be the first matrix in stack.
     *  @param clearScreen
     *  @param clearColor
     *  @param deltaMilliseconds Time assigned to calculate time-based animation.
     */
    public abstract void startRendering( boolean clearScreen, int clearColor, long deltaMilliseconds );
    
    /**
     *  Internal use only.
     *  \details Is called after rendering sequence.
     */
    public abstract void finishRendering();

    /**
     *  Get the property.
     *  @param propertyName
     *  @return Object assigned to the name.
     */
    public abstract Object getProperty( String propertyName );
    
    public abstract int getScreenWidth();
    public abstract int getScreenHeight();
    
    /**
     *  Set clipping.
     *  @param x
     *  @param y
     *  @param width
     *  @param height
     */
    public abstract void setClip( int x, int y, int width, int height );
    
    public final void setClip( Rectangle rect )
    {
        setClip( rect.x, rect.y, rect.w, rect.h );
    }
    
    public abstract long getClip();
    public abstract void getClip( Rectangle rect );
    
    public abstract void mulMatrix( Matrix4f trans );
    public abstract void rollbackMatrix();
    public abstract void getCurrentMatrix( Matrix4f trans );
    public abstract void setPlaneColor( int color );
    public abstract void setAdditionalColor( int color );
    public abstract void setBlending( boolean useBlending );
    
    /**
     *  For internal use only, do not manual call it.
     *  Render the entity at current transformation.
     *  @param entity
     */
    public abstract void render( Entity entity, boolean animating );
    
    public abstract ImageRegion createImageRegion( Image image, int x, int y, int w, int h );
    
    public final ImageRegion createImageRegion( Image image )
    {
        return createImageRegion( image, 0, 0, image.width(), image.height() );
    }
    
    public abstract Sprite createSprite( Image image, int x, int y, int w, int h,
        int spriteW, int spriteH, int[] framePositions, int[] frameSteps );
    
    public final Sprite createSprite( Image image, int spriteW, int spriteH,
        int[] framePositions, int[] frameSteps )
    {
        return createSprite( image, 0, 0, image.width(), image.height(),
            spriteW, spriteH, framePositions, frameSteps );
    }

    //! Standard property name. Returned object: String.
    //! \details Name of the implemented video API.
    public static final String PROPERTY_NAME            = "apiname";
    //! Standard property name. Returned object: String
    //! \details Version of the implemented video API.
    public static final String PROPERTY_VERSION         = "apiversion";
}
